<template>
<!--  新增编辑产品-->
  <div>
    <div class="padding15 minMaxWidth600 marginAuto">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
        <el-form-item label="产品名称" prop="name">
          <el-input :disabled="disabled" class="width100" v-model="ruleForm.name" placeholder="请输入产品名称"></el-input>
        </el-form-item>
       
        <el-form-item label="产品货号" prop="phone">
          <el-input :disabled="disabled" class="width100" v-model="ruleForm.phone" placeholder="请输入产品货号"></el-input>
        </el-form-item>
        <el-form-item label="产品分类" prop="phone">
          <el-cascader class="wid260"  v-model="ruleForm.phone":options="opctions"/>
        </el-form-item>
        <el-form-item label="产品宣传图" prop="phone">
           <UploadImg @callbackUrl='callbackUrl'/>
        </el-form-item>
        <el-form-item label="等级" prop="roleId">
          <el-select  :disabled='disabled' filterable style="width: 100%;" v-model="ruleForm.roleId" placeholder="请选择">
            <el-option v-for="(item,index) in roles" :key="index+'roleId'" :label="item.name" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="产品对换积分" prop="phone">
          <el-input class="width100" v-model="ruleForm.phone" placeholder="请输入会员积分"></el-input>
        </el-form-item>
        <el-form-item label="产品概要说明" prop="phone">
          <!-- <el-input class="width100" v-model="ruleForm.phone" placeholder="请输入会员备注"></el-input> -->
          <TEditor @editInput="editInput" :value="ruleForm.content"></TEditor>
        </el-form-item>
    
        <el-form-item>
          <el-button type="primary" :loading="isLoading" :submitDisbled="submitDisbled" @click="submitForm('ruleForm')">确定</el-button>
          <el-button @click="goback">返回</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
//  import {} from '@/assets/api/api'
import {AddEditmixin} from '@/assets/mixins/addEditmixin'
  export default {
    name:'AddEditProduct',
    mixins: [AddEditmixin],
    components:{
      UploadImg:()=>import('@/components/uploadImg.vue'),
      TEditor:()=>import('@/components/TEditor.vue'),
    },
    data(){
      return{
        opctions:[
        {
          value: 'zhinan',
          label: '指南',
          children: [{
            value: 'shejiyuanze',
            label: '设计原则',
            children: [{
              value: 'yizhi',
              label: '一致'
            }, {
              value: 'fankui',
              label: '反馈'
            }, {
              value: 'xiaolv',
              label: '效率'
            }, {
              value: 'kekong',
              label: '可控'
            }]
          }],
        }],
        goBackPath:'/product/productList',//返回的路径
          isLoading:false,
        page:this.$route.query.page?this.$route.query.page:1,
        submitDisbled:false,
          infoName:'',//编辑取得名字查重要
        msg1:'新增账号',
          roleName:'',//角色名称
        ruleForm:{
          content:"1",
          name: "",
          phone: "",
  
          expireDate:new Date().getTime(),
          roleId:'',
        
        },
        disabled:false,
        rules: {
          name: [
            { required: true, message: '请输入账号名', trigger: 'blur' },
            { min: 3, max: 20, message: '长度在 3 到 20 个字符', trigger: 'blur' },
          ],
          phone: [
            { required: true, message: '请输入手机号', trigger: 'blur' },
            { min: 11, max: 11, message: '请输入正确手机号', trigger: 'blur' },
          ],
          roleId: [
            { required: true, message: '请选择会员等级', trigger: 'change' },
          ]
        },
        products:[],
        organizations:[],
        roles:[],
      }
    },
    created() {
     
        
      },
    methods:{
      editInput(v){//富文本
          this.objData.content = v;
        },
      callbackUrl(url){//图片的上传地址
           console.log(url,'callbackUrl')
      },
     
      submitForm(formName) {
        let that = this;
        that.isLoading = true;
      
        this.$refs[formName].validate((valid) => {
          if (valid) {
        
            that.isLoading = false;
          } else {
            that.isLoading = false;
            return false;
          }
        });
      },
    }
  }
</script>
<style lang="scss" scoped>

</style>
